package com.gxa.service.commlife.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.commlife.CouponUse;
import com.gxa.dto.commlife.CouponUseDto;
import com.gxa.mapper.commlife.CouponUseMapper;
import com.gxa.service.commlife.CouponUseService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:00
 */
@Service
public class CouponUseServiceImpl extends ServiceImpl<CouponUseMapper, CouponUse> implements CouponUseService {
    @Autowired
    private CouponUseMapper couponUseMapper;

    @Override
    public Map<String,Object> queryList(Integer pageNum,Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        Page<CouponUse> page = PageHelper.startPage(pageNum,pageSize);
        List<CouponUse> couponUseList = this.couponUseMapper.queryList();
        PageInfo<CouponUse> pageInfo = new PageInfo<>(couponUseList);
        map.put("pageInfo",pageInfo);
        return map;
    }

    @Override
    public void addCouponUse(CouponUse couponUse) {
        this.couponUseMapper.addCouponUse(couponUse);

    }

    @Override
    public Map<String,Object> queryListBySearch(CouponUseDto couponUseDto,Integer pageNum,Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        Page<CouponUse> page = PageHelper.startPage(pageNum,pageSize);
        List<CouponUse> couponUseList = this.couponUseMapper.queryListBySearch(couponUseDto);
        PageInfo<CouponUse> pageInfo = new PageInfo<>(couponUseList);
        map.put("pageInfo",pageInfo);
        return map;
    }
}
